/*
 * @description: 
 * @Author: wzg
 * @Date: 2021-03-08 08:42:12
 * @LastEditTime: 2021-03-19 14:51:23
 */
import resultEnum from '../utils/resultEnum.js';
import Mocks from '../utils/mock.js';
const Mock = new Mocks();
import model from '../utils/model.js';
/* 查询收藏信息 */
export async function selectCollectInfo (ctx, next) {
  const params = {
    ...ctx.query
  };
  let Pet = model.Pet;
  console.log(model);
  let pets = await Pet.findAll({
    where: {
      name: params.name
    }
  });
  ctx.success(resultEnum.GET_SUCCESS.code, resultEnum.GET_SUCCESS.msg, pets);
}
/* 查询竞拍记录信息 */
export function selectAuctionRecordInfo (ctx, next) {
  try {
    const params = {
      ...ctx.query
    };
    console.log(params);
    /* 模拟查询数据库，处理后返回 */
    /* 返回对象 */
    if (Number(params.current) >= 3) {
      ctx.success(resultEnum.GET_SUCCESS.code, resultEnum.GET_SUCCESS.msg, Mock.getBlankInfo())
    } else {
      ctx.success(resultEnum.GET_SUCCESS.code, resultEnum.GET_SUCCESS.msg, Mock.getAuctionRecordList())
    }
  } catch (error) {
    ctx.error(resultEnum.GET_ERROR.code, resultEnum.GET_ERROR.msg)
  }
}
// export default {
//   selectCollectInfo,
//   selectAuctionRecordInfo
// }